<%@ page import="java.util.Arrays" %><%--
  Created by IntelliJ IDEA.
  User: koizumisinya
  Date: 2017/12/05
  Time: 11:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--页面提供登陆提供表单，以及登陆失败时候应该显示的错误信息--%>

<h1>登陆</h1>
<%
    String cookieUserName = "";
    Cookie[] cookies = request.getCookies();

    if (cookies != null) {
        for (Cookie c : cookies) {
            if ("cookieUserName".equals(c.getName())) {
                cookieUserName = c.getValue();
            }
        }
    }
%>
<%
    String errorMsg = "";
    String msg = (String) request.getAttribute("error");
    if (null != msg && !"".equals(msg)) {
        errorMsg = msg;
    }
%>


<p><%=errorMsg%>
</p>

<form action="/Demo1/session/LoginServlet" method="post">
    用户名: <input type="text" name="username" value="<%=cookieUserName%>"/><br/>
    密 码: <input type="password" name="password"/><br/>
    <input type="submit" name="submit" value="登陆"/>
</form>

</body>
</html>
